package controle;
import java.util.List;
import javax.enterprise.context.ApplicationScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.inject.Inject;
import javax.inject.Named;
import modelo.TimeRepository;
import entidades.Time;
@Named("timeMB")
@ApplicationScoped
public class TimeMB {
	@Inject
	private Time time;
	@Inject
	private TimeRepository repository;
	public String adiciona() {
		repository.adiciona(this.time);
		this.time = new Time();
		return null;
	}
	public String remove(ActionEvent event) {
		Long id = Long.parseLong(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id"));
		time.setId(id);
		repository.remove(time);
		return null;
	}
	public List<Time> getTimes() {
		return repository.recuperaTimes();
	}
	public void setTime(Time time) {
		this.time = time;
	}
	public Time getTime() {
		return time;
	}
}